package com.sy;

import java.util.Date;
import java.util.Scanner;

import org.dom4j.Element;

import com.dl.DL;
import com.dom4j.XF;
import com.dom4j.YM;
import com.test.Test;

public class SY {
	static Scanner in = new Scanner(System.in);
//使用嗖嗖界面
	public static void SY(boolean boo) {
		if (boo) {
			Date date = new Date();
			System.out.println("1.上网");
			System.out.println("2.拨打电话");
			System.out.println("3.发短信");
			System.out.println("4.结束程序");
			System.out.println("5.返回主界面");
			if (in.hasNextInt()) {
				int a = in.nextInt();
				String aXF = XF.date();
				long time = date.getTime();
				long t = time % 100000;
				long time1 = 0;
				long t1 = 0;
				long t2 = 0;
				String b = "1";
				String bXF = null;
				Element element = YM.zxSJH(DL.num, YM.root);
				String ye = element.element("密码").element("余额")
						.attributeValue("num");
				int ye1 = Integer.valueOf(ye);
				if (ye1 > 0) {

					switch (a) {
					case 1:
						System.out.println("已开始计费");
						System.out.println("按1则终止上网");
						while (!b.equals(in.next())) {
							System.out.println("不想上网请按1");
						}
						time1 = new Date().getTime();
						t1 = time1 % 100000;
						t2 = t1 - t;
						t2 = t2 / 1000 + 1;
						bXF = XF.date();
						XF.XF(aXF, bXF, "上网");
						YM.xf(t2, "上网流量", "MB");
						SY(boo);
						break;
					case 2:
						System.out.println("已开始计费");
						System.out.println("按1则终止通话");
						while (!b.equals(in.next())) {
							System.out.println("不想通话请按1");
						}
						time1 = new Date().getTime();
						t1 = time1 % 100000;
						t2 = t1 - t;
						t2 = t2 / 1000 / 60 + 1;
						bXF = XF.date();
						XF.XF(aXF, bXF, "通话");
						YM.xf(t2, "通话时间", "分钟");
						SY(boo);
						break;
					case 3:
						System.out.println("已开始计费");
						System.out.println("正在自动发短信，俩秒钟自动发一条，按1则终止短信");
						while (!b.equals(in.next())) {
							System.out.println("不想继续请按1");
						}
						time1 = new Date().getTime();
						t1 = time1 % 100000;
						t2 = t1 - t;
						t2 = t2 / 1000 / 2 + 1;
						bXF = XF.date();
						XF.XF(aXF, bXF, "短信");
						YM.xf(t2, "短信条数", "条");
						SY(boo);
						break;
					case 4:
						System.exit(0);
						break;
					case 5:
						Test.zjm();
						break;
					default:
						SY(boo);
						break;
					}
				}else{
					System.out.println("余额不足,请充值");
					Test.zjm();
				}
			} else {
				System.out.println("请输入数字");
				Test.zjm();
			}

		}

	}
}
